﻿(function () {
    'use strict';
    var app = angular.module('app');
app.directive('onEnter', function () {

    var linkFn = function (scope, element, attrs) {
        element.bind("keypress", function (event) {
            if (event.which === 13) {
                scope.$apply(function () {
                    scope.$eval(attrs.onEnter);
                });
                event.preventDefault();
            }
        });
    };

    return {
        link: linkFn
    };
});
app.directive('focusMe', function () {
    return {
        link: function (scope, element, attrs) {
            scope.$watch(attrs.focusMe, function (value) {
                if (value === true) {
                    element[0].focus();
                    scope[attrs.focusMe] = false;
                }
            });
        }
    };
});
}());